<?php
namespace app\index\controller;
use app\model\Order as OrderModel;
use app\model\Product as ProductModel;
use think\Db;


class Order extends Base
{
    public function __construct(){
        $model = new OrderModel();
        $this->model = $model;
        parent::__construct();
        
        $page_info = $this->page_info;
        $page_info['title'] = '产品';

        $this->assign([
            'model'=>$this->model,
            'page_info'=>$page_info
        ]);
    }

   
    public function index(){
        $model = $this->model;
        $list = Db::name('order')->where([
            ['user_id','=',$this->login_user['id']]
        ])->select();
        foreach ($list as $k => $vo) {
            $list[$k]['product'] = Db::name('product')->where('id',$vo['product_id'])->find();
            $list[$k]['status_cn'] = $model->getStatusCn($vo['status']);
        }

        $price_types = ProductModel::getPriceTypeList();
        return view('index', [
            'list'=>$list,
            'price_types'=>$price_types
        ]);
    }


    
}
